from fastapi import APIRouter
from utils.tools import logger
from app.funcs import alert_wechat

from app.module.entity.vo.task_state_vo import TaskStatusModel

wechatController = APIRouter()


@wechatController.get("/wechat/")
def alert_wechat_api(wx_name="exlo", message: str = "这是一个测试告警"):
    """接口直接最大阻塞120s直到任务执行完成"""
    async_result = alert_wechat.push(wx_name, message)
    logger.debug(f"返回taskid给前端： [{async_result.task_id}]")
    model = TaskStatusModel(task_id=async_result.task_id)
    return model
